package com.xuxin.baby.activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.ActivityUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.xuxin.baby.R;
import com.xuxin.baby.adapter.ChildRiskAdapter;
import com.xuxin.baby.base.BaseActivity;
import com.xuxin.baby.base.BaseConstant;
import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.contract.ChildRiskContract;
import com.xuxin.baby.presenter.ChildRiskPresenter;
import com.xuxin.baby.utils.RecycleUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by xu_xin
 * Created on 2020.08.21 0021
 * 0-12个月的危险信号
 */
public class ChildRiskActivity extends BaseActivity implements ChildRiskContract.View {
    private final ChildRiskContract.Presenter presenter = new ChildRiskPresenter(this);
    @BindView(R.id.title_left)
    ImageView title_left;
    @BindView(R.id.title_right)
    ImageView title_right;
    @BindView(R.id.title_name)
    TextView title_name;
    @BindView(R.id.smart_refresh)
    SmartRefreshLayout smart_refresh;
    @BindView(R.id.smart_recycle)
    RecyclerView smart_recycle;

    private ChildRiskAdapter myAdapter;

    @Override
    public void setContentView() {
        setContentView(R.layout.activity_smart);
    }

    @Override
    public void initView() {
        title_name.setText("0-12个月的危险信号");
        smart_refresh.setEnableRefresh(false);
        smart_refresh.setEnableLoadMore(false);
        RecycleUtils.init(smart_recycle);
        myAdapter = new ChildRiskAdapter();
        smart_recycle.setAdapter(myAdapter);
        myAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                int ageRge = position + 1;
                Bundle bundle = new Bundle();
                bundle.putString("title", String.valueOf("宝宝" + ageRge + "个月危险信号"));
                bundle.putString("categoryId", BaseConstant.categoryId_risk);
                bundle.putString("ageRge", String.valueOf(position*30 + "," + ageRge*30));
                ActivityUtils.startActivity(bundle, ReaderVideoSlidingActivity.class);
            }
        });
    }

    @Override
    public void initData() {
        myAdapter.notifyDataSetChanged();
    }

    @Override
    public void onComplete() {

    }

    @Override
    @OnClick({R.id.title_left})
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.title_left) {
            finish();
        }
    }

    private final Handler handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(@NonNull Message msg) {
            switch (msg.what) {
                case 0:
                    break;
            }
            return false;
        }
    });

    @Override
    public void onSuccess(BaseBean baseBean) {

    }
}